package org.xx.armory.swing;

import java.awt.Component;
import java.awt.event.ComponentEvent;
import java.io.Serializable;

import static org.xx.armory.commons.Validators.greaterThanOrEqual;
import static org.xx.armory.commons.Validators.notNull;

public final class ApplicationEvent
        implements Serializable {
    public static final int APPLICATION_START_UP = 10001;
    public static final int APPLICATION_EXIT = 10002;
    private static final long serialVersionUID = 1L;

    private Application source;
    private int id;

    /**
     * 构造应用程序事件对象。
     *
     * @param source
     *         事件的源。
     * @param id
     *         事件的ID。
     * @see ComponentEvent#ComponentEvent(Component, int)
     */
    public ApplicationEvent(
            Application source,
            int id
    ) {
        this.source = notNull(source, "source");
        this.id = greaterThanOrEqual(id, "id", 1);
    }

    public Application getSource() {
        return this.source;
    }

    public int getID() {
        return this.id;
    }
}
